import java.util.Arrays;

/*
 * @lc app=leetcode.cn id=506 lang=java
 *
 * [506] 相对名次
 */

// @lc code=start
class FindRelativeRanks {
  public String[] findRelativeRanks(int[] score) {
    int n = score.length;
    int[][] arr = new int[n][2];
    for (int i = 0; i < n; i++) {
      arr[i][0] = score[i];
      arr[i][1] = i;
    }
    Arrays.sort(arr, (a, b) -> b[0] - a[0]);
    String[] res = new String[n];
    String[] desc = { "Gold Medal", "Silver Medal", "Bronze Medal" };
    for (int i = 0; i < n; i++) {
      if (i >= 3) {
        res[arr[i][1]] = Integer.toString(i + 1);
      } else {
        res[arr[i][1]] = desc[i];
      }
    }
    return res;
  }
}
// @lc code=end
